<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1" import="java.sql.*" errorPage=""%>
<%@page import="org.w3c.dom.*, javax.xml.parsers.*" %>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.List"%>
<%@ page import="comits.business.tiers.metiers.ScanneProduits"%>
<%@ page import="java.util.Iterator"%>
<%@ page import="comits.web.client.servlets.demo.*"%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="d"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- DW6 -->
<head>
<!-- Copyright 2005 Macromedia, Inc. All rights reserved. -->
<title>Comits Web Client - Listes Produits Scannes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="mm_entertainment.css" type="text/css" />
<link href="./Style.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<%
		ArrayList<ScanneProduits> lstScanProduits = new ArrayList<ScanneProduits>();
		try
		{
			//PropertiesConfig.class.getResourceAsStream
			String XmlPath = "C://Documents and Settings//Marny//Bureau//xml//scanne.xml";
	%>
	<%!
		Document doc;
		String getTagValue(String sTag, Element eElement) 
		{
			NodeList nlList = eElement.getElementsByTagName(sTag).item(0).getChildNodes();
	        Node nValue = (Node) nlList.item(0);
			return nValue.getNodeValue();
	  }
	%>
	<%
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		DocumentBuilder db = dbf.newDocumentBuilder();
		doc = db.parse(XmlPath);
		NodeList nList = doc.getElementsByTagName("produit");
		for (int temp = 0; temp < nList.getLength(); temp++) 
		{
			   Node nNode = nList.item(temp);
			   if (nNode.getNodeType() == Node.ELEMENT_NODE)
			   {
	 
			      Element eElement = (Element) nNode;
			      ScanneProduits unScanProduit = new ScanneProduits();
	              unScanProduit.setIdProduit(getTagValue("id", eElement));
	              unScanProduit.setNumCmd(getTagValue("NumCmd", eElement));
	              unScanProduit.setTypeProduit(getTagValue("TypeProduit", eElement));
	              unScanProduit.setNumPdt(getTagValue("NumPdt", eElement));
	              unScanProduit.setQte(getTagValue("Quantite", eElement));
	              unScanProduit.setNumSite(getTagValue("NumSite", eElement));
	              unScanProduit.setSite(getTagValue("Site", eElement));
	              lstScanProduits.add(unScanProduit);
			   }
		}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	%>
	<table width="100%" border="0" cellspacing="0" cellpadding="0"
		align="center" border=1>
		<tr bgcolor="02021e">
			<td width="410" nowrap="nowrap"><img src="images/vin.jpg"
				width="400" height="140" border="0" />
			</td>
			<td colspan="2" valign="center" nowrap="nowrap" id="logo">OENOLOGISTICS</td>
		</tr>
		<tr>
			<td colspan="3" id="dateformat" height="30"><jsp:include
					page="menu.jsp" />
			</td>
		</tr>
		<tr>
			<td colspan="3" valign="top"><br />
					<form action="MenuDepotServlet" method="get">
						<table border="0" cellspacing="0" cellpadding="2" width="80%" align="center" border=1>
							<tr>
								<td>&nbsp;</td>
							</tr>
							<tr>
								<td class="subHeader" align="center">PRODUITS SCANNES</td>
							</tr>
							</br></br>
							<tr>		
							<table id="table" border="1" align="center">
								<tr BGCOLOR="02021e" >
		        					<center><td><font color="orangered"><b>Liste des numeros de commandes</b></font></td></center>
		        					<center><td><font color="orangered"><b>Action</b></font></td></center>
		        				</tr>
		        					<%
		        						ScanneProduits majScan = new ScanneProduits();
		        						majScan.majListScanneProduits(lstScanProduits);
		        						ArrayList<Integer> lstNumCmd =  majScan.getListNumCmdScanProduit();
		        						int unNumeroCmd = 0;
										for(int i = 0; i < lstNumCmd.size(); i++)
										{
											unNumeroCmd = lstNumCmd.get(i);
		   							%>
		   						<tr>
		   							<td><%=unNumeroCmd%></td>	
	        						<td><a href="MenuDepotServlet?action=AfficherDetailsScan&numCommande=<%=unNumeroCmd%>">Afficher</a></td>
	        					</tr>
		        					<% 
 										}
 									%>
		      				</table>												
						</table>
					</form>			
				</td>
			</tr>
		</table>
</body>
</html>